﻿@inherits RadzenComponent
@if (GetVisible())
{
    <div @ref="@Element" @attributes="Attributes" class="@GetCssClass()" style="@Style" id="@GetId()">
        @if(ShowPagingSummary)
        {
        <label class="rz-paginator-summary">@((MarkupString)string.Format(PagingSummaryFormat, CurrentPage + 1, numberOfPages, Count))</label>        
        }

        <a class="rz-paginator-first rz-paginator-element @((skip > 0) ? "": "rz-state-disabled")" href="javascript:void(0)" tabindex="-1" @onclick:preventDefault="true" @onclick="@(() => FirstPage())" aria-label="@FirstPageAriaLabel" title="@FirstPageTitle">
            <span class="rz-paginator-icon rzi rzi-step-backward"></span>
        </a>
        <a class="rz-paginator-prev rz-paginator-element @((skip > 0) ? "": "rz-state-disabled")" href="javascript:void(0)" tabindex="-1" @onclick:preventDefault="true" @onclick="@(() => PrevPage())" aria-label="@PrevPageAriaLabel" title="@PrevPageTitle">
            <span class="rz-paginator-icon rzi rzi-caret-left"></span>
        </a>

        <span class="rz-paginator-pages">
            @foreach (var i in Enumerable.Range(startPage, Math.Min(endPage + 1, PageNumbersCount)))
            {
                <a class="rz-paginator-page rz-paginator-element @((i == CurrentPage) ? "rz-state-active" : "")" href="javascript:void(0)" @onclick:preventDefault="true" @onclick="@(() => GoToPage(i))"  aria-label="@string.Format(PageAriaLabelFormat, (i + 1).ToString())" title="@string.Format(PageTitleFormat, (i + 1).ToString())">@(i + 1)</a>
            }
        </span>
        <a class="rz-paginator-next rz-paginator-element @((CurrentPage != numberOfPages - 1) ? "": "rz-state-disabled")" href="javascript:void(0)" tabindex="0" @onclick:preventDefault="true" @onclick="@(() => NextPage())" aria-label="@NextPageAriaLabel" title="@NextPageTitle">
            <span class="rz-paginator-icon rzi rzi-caret-right"></span>
        </a>
        <a class="rz-paginator-last rz-paginator-element  @((CurrentPage != numberOfPages - 1) ? "": "rz-state-disabled")" href="javascript:void(0)" tabindex="0" @onclick:preventDefault="true" @onclick="@(() => LastPage())" aria-label="@LastPageAriaLabel" title="@LastPageTitle">
            <span class="rz-paginator-icon rzi rzi-step-forward"></span>
        </a>

        @if(PageSizeOptions != null && PageSizeOptions.Any())
        {
            <RadzenDropDown TValue="int" Data="@PageSizeOptions" Value="@PageSize" Change="@OnPageSizeChanged" />
            <span class="rz-pagesize-text">@PageSizeText</span>
        }
    </div>
}
